import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus';  // 引入 Element Plus
import 'element-plus/dist/index.css';    // 引入样式文件
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'  // 引入中文语言包
import './global.less'
import hasRole from '@/directive/permission/hasRole'

// 导入图标组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App);

// 注册指令
app.directive('role', hasRole)

// 全局注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  //@ts-ignore
  app.component(key, component)
}

app.use(ElementPlus, {
  locale: zhCn,  // 设置语言为中文
});                   // 全局注册组件
app.use(store);
app.use(router);
app.mount('#app');
